package com.chuangjiangx.member.basic.ddd.domain.model;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/**
 * 存贮用户信息
 * Created by YangKuo on 2017/11/14.
 */
@Data
@Builder
public class MbrUserContext implements Serializable {

    /**
     * 会员id
     */
    private Long memberId;
    /**
     * 会员姓名
     */
    private String name;
    /**
     * 微信头像地址
     */
    private String headimgurl;

    private Byte sex;

    /**
     * 会员手机号码
     */
    private String mobile;

    /**
     * 所属商户id
     */
    private Long merchantId;
    /**
     * 商户微信公众号AppId
     */
    private String merchantWxAppid;
    /**
     * 服务商appid
     */
    private String wxisvAppid;

    /**
     * 所属商户用户id
     */
    private Long merchantUserId;

    /**
     * 服务商公众号下openid
     */
    private String openId;
    /**
     * 商户公众号下openid
     */
    private String mopenId;

    private MbrUserMappingType mbrUserMappingType;

    private State state;
    /**
     * 会员小程序的openId
     */
    private String subOpenId;

    /**
     * 小程序appId
     */
    private String subAppId;

    /**
     * AI活体检测返回的图片路径
     */
    private String aiFaceImg;
    /**
     * 人脸Id
     */
    private String faceId;

    public MbrUserContext() {
    }

    public MbrUserContext(Long memberId, String name, String headimgurl, Byte sex, String mobile, Long merchantId, String merchantWxAppid, String wxisvAppid, Long merchantUserId, String openId, String mopenId, MbrUserMappingType mbrUserMappingType, State state, String subOpenId, String subAppId, String aiFaceImg, String faceId) {
        this.memberId = memberId;
        this.name = name;
        this.headimgurl = headimgurl;
        this.sex = sex;
        this.mobile = mobile;
        this.merchantId = merchantId;
        this.merchantWxAppid = merchantWxAppid;
        this.wxisvAppid = wxisvAppid;
        this.merchantUserId = merchantUserId;
        this.openId = openId;
        this.mopenId = mopenId;
        this.mbrUserMappingType = mbrUserMappingType;
        this.state = state;
        this.subOpenId = subOpenId;
        this.subAppId = subAppId;
        this.aiFaceImg = aiFaceImg;
        this.faceId = faceId;
    }

    public static class MbrUserContextBuilder {
        private Long memberId;
        private String name;
        private String headimgurl;
        private Byte sex;
        private String mobile;
        private Long merchantId;
        private String merchantWxAppid;
        private String wxisvAppid;
        private Long merchantUserId;
        private String openId;
        private String mopenId;
        private MbrUserMappingType mbrUserMappingType;
        private MbrUserContext.State state;
        private String subOpenId;
        private String subAppId;
        private String aiFaceImg;
        private String faceId;

        MbrUserContextBuilder() {
        }

        public MbrUserContext.MbrUserContextBuilder memberId(Long memberId) {
            this.memberId = memberId;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder name(String name) {
            this.name = name;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder headimgurl(String headimgurl) {
            this.headimgurl = headimgurl;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder sex(Byte sex) {
            this.sex = sex;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder mobile(String mobile) {
            this.mobile = mobile;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder merchantId(Long merchantId) {
            this.merchantId = merchantId;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder merchantWxAppid(String merchantWxAppid) {
            this.merchantWxAppid = merchantWxAppid;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder wxisvAppid(String wxisvAppid) {
            this.wxisvAppid = wxisvAppid;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder merchantUserId(Long merchantUserId) {
            this.merchantUserId = merchantUserId;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder openId(String openId) {
            this.openId = openId;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder mopenId(String mopenId) {
            this.mopenId = mopenId;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder mbrUserMappingType(MbrUserMappingType mbrUserMappingType) {
            this.mbrUserMappingType = mbrUserMappingType;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder state(MbrUserContext.State state) {
            this.state = state;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder subOpenId(String subOpenId) {
            this.subOpenId = subOpenId;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder subAppId(String subAppId) {
            this.subAppId = subAppId;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder aiFaceImg(String aiFaceImg) {
            this.aiFaceImg = aiFaceImg;
            return this;
        }

        public MbrUserContext.MbrUserContextBuilder faceId(String faceId) {
            this.faceId = faceId;
            return this;
        }

        public MbrUserContext build() {
            return new MbrUserContext(this.memberId, this.name, this.headimgurl, this.sex, this.mobile, this.merchantId, this.merchantWxAppid, this.wxisvAppid, this.merchantUserId, this.openId, this.mopenId, this.mbrUserMappingType, this.state, this.subOpenId, this.subAppId, this.aiFaceImg, this.faceId);
        }

        public String toString() {
            return "MbrUserContext.MbrUserContextBuilder(memberId=" + this.memberId + ", name=" + this.name + ", headimgurl=" + this.headimgurl + ", sex=" + this.sex + ", mobile=" + this.mobile + ", merchantId=" + this.merchantId + ", merchantWxAppid=" + this.merchantWxAppid + ", wxisvAppid=" + this.wxisvAppid + ", merchantUserId=" + this.merchantUserId + ", openId=" + this.openId + ", mopenId=" + this.mopenId + ", mbrUserMappingType=" + this.mbrUserMappingType + ", state=" + this.state + ", subOpenId=" + this.subOpenId + ", subAppId=" + this.subAppId + ", aiFaceImg=" + this.aiFaceImg + ", faceId=" + this.faceId + ")";
        }
    }


    public enum State{
        /**
         * 非会员状态
         * 根据openid查询不到的会员
         */
        NON_MEMBERS,
        /**
         * 正式会员状态
         * 资料完善的会员,手机号\openid\mopenid\头像都有
         */
        MEMBER,
        /**
         * 支付即会员状态
         * 资料不完善的会员,手机号\openid\mopenid\头像中有些没有,需要补充
         */
        PAYMENT_IS;
    }
}
